#include "head.h"

// mkdir
int mkdir_(const me_t* me, int sock_fd, char* cmd)
{
    messenger_t msg;
    bzero(&msg, sizeof(msg));

    msg.cmd = MKDIR;

    while(*cmd++ != ' ');
    sprintf(msg.args, "%s&%s", me->path, cmd);
    sprintf(msg.token, "%s", me->token);
    printf("args = %s\n", msg.args);

    send(sock_fd, &msg, sizeof(msg), MSG_NOSIGNAL);

    char reply[20] = {0};
    recv(sock_fd, reply, 8, 0);

    if(strcmp(reply, "faileded") == 0)
    {
        // 有这个文件夹了
        printf("不可以创建同名文件夹\n");
        return -1;
    }
    else if(strcmp(reply, "succeedd") == 0)
    {
        // 成功
        printf("创建成功\n");
        pwd(me);
        return 0;
    }

    
}